<template>
  <div class="animated fadeIn">
    <div class="card card-accent-primary">
      <div class="card-header">
        <i class="fa fa-align-justify"></i> 接口列表
      </div>
      <div class="card-body">
        <i-table :loading="loading" border :columns="columns" :data="items"></i-table>
        <div style="margin: 10px;overflow: hidden">
          <Page :total="total" :page-size="10" show-total></Page>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data () {
    return {
      key: '',
      columns: [
        {
          title: 'ID',
          key: 'api_id',
          width: 50
        },
        {
          title: '接口名称',
          key: 'api_name',
          width: 200
        },
        {
          title: '接口url',
          key: 'api_url',
          width: 200
        },
        {
          title: '请求方式',
          key: 'api_method',
          width: 200
        },
        {
          title: '操作',
          key: 'action',
          align: 'center',
          className: 'table-min-width'
        }
      ],
      items: [],
      total: 0,
      page: 1,
      loading: true
    }
  },
  methods: {
    // 获取列表
    getList () {
      this.$get('/api/user/api', {
        params: {
          page: this.page
        }
      }).then((res) => {
        if (res) {
          this.total = res.data.total
          this.items = res.data.data
          this.loading = false
        }
      })
    }
  },
  created () {
    this.getList()
  }
}
</script>
<style>
  /*解决table表格适应问题*/
  .table-min-width {
    min-width: 200px;
    width: 200px;
  }
</style>
